<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page isELIgnored="false"%>
<c:set var="cp" scope="session" value="${pageContext.request.servletContext.contextPath}"/>

<html>

<script type="text/javascript" src="${cp}/js/jquery.min.js"></script>

<body>
	<h1>支付页面</h1>
	
	<span>订单总金额：${amount }元</span>
	支付密码：<input type="password" name="payPassword" id="payPassword">
	<input type="button" value="确认支付" onclick="confirmPay();">
	<div id="payFormDiv" style="display:none;"></div>
</body>

<script type="text/javascript">
var payId = ${payId};
	function confirmPay() {
		$.ajax({
		    url:'${cp}/payOrder/confirmPay.do',
		    type:'POST', //GET
		    async:false,
		    data:{
		    	payId : payId,
		    	payPasswrod : $('#payPassword').val()
		    },
		    timeout:5000,    //超时时间
		    dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
		    success:function(data){
		    	
		    	if (data.success) {
					$('#payFormDiv').html(data.data.bankForm);
					$('#payForm').submit();
		    	} else {
		    		alert(data.message);
		    	}
		    },
		    error:function(xhr,textStatus){
		        console.log('错误')
		        console.log(xhr)
		        console.log(textStatus)
		    },
		    complete:function(){
		        console.log('结束')
		    }
		});
	}
</script>

</html>